package com.cyw.common.config.mongo;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.mongodb.MongoDatabaseFactory;
import org.springframework.data.mongodb.MongoTransactionManager;

/**
 * mongodb 事务配置
 * @author cyw
 * @date 2021-01-18
 */
@Configuration
public class MongoTransactionConfig {

    /**
     * 需要配置主从 才能开启事务...
     */
    @Bean
    public MongoTransactionManager transactionManager(MongoDatabaseFactory mongoDatabaseFactory) {
        return new MongoTransactionManager(mongoDatabaseFactory);
    }
}